package com.web.mqtt.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.web.common.iot.mqtt.api.MqttListenApi;
import com.web.common.iot.mqtt.entity.MqttConnectedListener;
import com.web.common.iot.mqtt.entity.MqttDeliveredListener;
import com.web.common.iot.mqtt.entity.MqttDisconnectedListener;
import com.web.common.iot.mqtt.entity.MqttDroppedListener;
import com.web.common.iot.mqtt.entity.MqttSubscribedListener;
import com.web.common.result.R;
import com.web.mqtt.service.impl.MqttListenServiceImpl;
import com.web.service.handler.log.IgnoreOperateLogs;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;

@Tag(name = "MQTT消息、事件监听")
@Controller
@RequestMapping("/iot/mqtt/listen")
public class MqttListenController implements MqttListenApi {
	
	@Autowired
	private MqttListenServiceImpl mqttListenServiceImpl;

	@IgnoreOperateLogs
	@Operation(summary = "MQTT连接完成")
	@Override
	public R<Object> connectedEvent(MqttConnectedListener connected) {
		return mqttListenServiceImpl.connectedEvent(connected);
	}

	@IgnoreOperateLogs
	@Operation(summary = "MQTT连接断开")
	@Override
	public R<Object> disconnectedEvent(MqttDisconnectedListener disconnected) {
		return mqttListenServiceImpl.disconnectedEvent(disconnected);
	}

	@IgnoreOperateLogs
	@Operation(summary = "MQTT主题订阅")
	@Override
	public R<Object> subscribedEvent(MqttSubscribedListener subscribed) {
		return mqttListenServiceImpl.subscribedEvent(subscribed);
	}

	@IgnoreOperateLogs
	@Operation(summary = "MQTT主题取消订阅")
	@Override
	public R<Object> unsubscribedEvent(MqttSubscribedListener subscribed) {
		return mqttListenServiceImpl.unsubscribedEvent(subscribed);
	}

	@IgnoreOperateLogs
	@Operation(summary = "MQTT消息投递")
	@Override
	public R<Object> deliveredEvent(MqttDeliveredListener delivered) {
		return mqttListenServiceImpl.deliveredEvent(delivered);
	}

	@IgnoreOperateLogs
	@Operation(summary = "MQTT消息丢弃")
	@Override
	public R<Object> droppedEvent(MqttDroppedListener dropped) {
		return mqttListenServiceImpl.droppedEvent(dropped);
	}
}
